package com.easy.dfc.entity;

import com.easy.common.util.Utility;
import com.easy.dfc.Utils.OrderInfoUtil2_0;

import java.util.Date;
import java.util.Map;

public class AliPayInfo {
    private String appId = "2017022705930080";
    private String sellerId = "payment@dfcapp.com";
    private String privateKey = "MIIEvAIBADANBgkqhkiG9w0BAQEFAASCBKYwggSiAgEAAoIBAQDEvsUfbXlGCi2PgVsuW/J86qbpVq+kLBB8QKUpZukGb9f2AUA3QUmkFAYuMQhJNdJM8pXhXidLLsy6ZBD0tfHwi3Yu3lDLf3Osv8qPYVRD1UGy6HqL4uXRb/Vtb7jO0immcM5LacLIh4jB5mmJudMKkhJvdpzNL0XbG2aLcTmncwGIigGwP0Wm6lU8qLvMcHyhfPpxvi83v+vRA5jkNcR36Cc37T8Op5enFzEhxF+P+7jlhv1k0Rqh1jyeVSs80j7dkm4s5v/TDVBSN9rZfcn9MUGQg+IguTZr7aeI8ScM0OU9JnUbZI0Itkhle531ET6pUH88GiUaUARqhGvW5oUzAgMBAAECggEAG5tZNau61KUg934DOWIViIm0mhFb3AGC3qyDgGe8UvbmqtJKHHbAypE0vM6MhxlSRRHVDiaUBOywNYdNCcluBX7MOo9fbu6XYKoY1j2mAU6vRVdxuqc/8D9xhMWkfQDobz5s9BAHEPRTsEGQlY7JmjYc+B8AqZn0h2Y04WQl3uT5DrghZwCWbde87RnO99c/gmcS8DYVfCC8Q//Hs5TNQp3GhQa/1PZ/uVOfQnKidnvN4llBTkhpJ+DQK7kF0N5nVph8CRY83BFBkZTw7654d2+Q+n5sDFwVX17jJ1+QnE4S/qRDhnzxWBX/rBtzP0ZRQu/TIQ5Vu1vSr38BlprAYQKBgQD3RYg8HFABXoJQcdClW8nv6Ke3X5I9fR0ii7Ei2ZFMoNUunY0+165I2qRx3/1vI1L6mWkJMvKgFaplQhMkshkxlZVHrf5RLb/BbykgjgjjnlEV8Oo8w2G3I8MvNzMKdHvXfETdPZgrRANEPnORaIoZczI9S3KBctb5QU+x01SlPQKBgQDLsKgEoK9Pd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";
    private String unitName = "大风车商城";
    private boolean rsa2 = true;


    public String getAppId() {
        return appId;
    }

    public void setAppId(String appId) {
        this.appId = appId;
    }

    public String getSellerId() {
        return sellerId;
    }

    public void setSellerId(String sellerId) {
        this.sellerId = sellerId;
    }

    public String getPrivateKey() {
        return privateKey;
    }

    public void setPrivateKey(String privateKey) {
        this.privateKey = privateKey;
    }

    public String getPublicKey() {
        return publicKey;
    }

    public void setPublicKey(String publicKey) {
        this.publicKey = publicKey;
    }

    public String getUnitName() {
        return unitName;
    }

    public void setUnitName(String unitName) {
        this.unitName = unitName;
    }

    public boolean isRsa2() {
        return rsa2;
    }

    public void setRsa2(boolean rsa2) {
        this.rsa2 = rsa2;
    }

    public String getAliPayInfo(PayProductInfo info) {

        Map<String,String> params = OrderInfoUtil2_0.buildOrderParamMap(this.appId, rsa2);
        params.put("biz_content", "{\"timeout_express\":\"30m\",\"product_code\":\"QUICK_MSECURITY_PAY\",\"total_amount\":\""+ Utility.getAmountStr(info.getTotalAmnt())+"\",\"subject\":\""+this.unitName+"\",\"body\":\""+info.getProductName()+"\",\"out_trade_no\":\"" + info.getTradeNo() +  "\"}");
        params.put("timestamp", Utility.getCurDateTimeStr());
        params.put("notify_url", info.getNotifyUrl());

        String orderParam = OrderInfoUtil2_0.buildOrderParam(params);
        String sign = OrderInfoUtil2_0.getSign(params, privateKey, rsa2);
        String orderString = orderParam +"&"+sign;

        return orderString;
    }
}